<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>信息管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
			
			$("#assignButton").click(function(){
				top.$.jBox.open("iframe:${ctx}/admin/houseMessage/selectUser", "选择人员",810,$(top.document).height()-340,{
					buttons:{"确定":"ok", "关闭":true}, bottomText:"通过选择部门，然后选择人员。",submit:function(v, h, f){
						var u = h.find("iframe")[0].contentWindow.user;
						//nodes = selectedTree.getSelectedNodes();
						if (v=="ok"){
							$("#toU").val(u.id);
							$("#toUName").val(u.name);
					    	return true;
						} else if (v=="clear"){
							h.find("iframe")[0].contentWindow.clearAssign();
							return false;
		                }
					}, loaded:function(h){
						$(".jbox-content", top.document).css("overflow-y","hidden");
					}
				});
			});
			
		});
		
		
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/admin/houseMessage/">信息列表</a></li>
		<li class="active"><a href="${ctx}/admin/houseMessage/form?id=${houseMessage.id}">信息<shiro:hasPermission name="admin:houseMessage:edit">${not empty houseMessage.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="admin:houseMessage:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="houseMessage" action="${ctx}/admin/houseMessage/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="msgType" value="1"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">收信人:</label>
			<div class="controls">
				<form:hidden path="toU" id="toU"/>
				<form:input path="toUName" id="toUName" htmlEscape="false" maxlength="32" class="input-xlarge " readonly="true"/>
				<input id="assignButton"  width="100%"  type="button" value="选择收信人"/>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">内容：</label>
			<div class="controls">
				<form:textarea path="content" htmlEscape="false" rows="4" maxlength="256" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="admin:houseMessage:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="发 送"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>